const defaultOptions = {
    selector: '#poster'
};
function Poster(options = {}, that) {
    options = {
        ...defaultOptions,
        ...options
    };
    const pages = getCurrentPages();
    let ctx = pages[pages.length - 1];
    if (that) {
        ctx = that;
    }
    
    // 兼容 uni-app 的组件选择方式
    let poster;
    if (ctx.zpSelectComponent) {
        poster = ctx.zpSelectComponent(options.selector);
    } else if (ctx.$refs && ctx.$refs.poster) {
        poster = ctx.$refs.poster;
    } else {
        // 尝试通过选择器查找
        poster = ctx.selectComponent(options.selector);
    }
    
    delete options.selector;
    return poster;
}
Poster.create = (reset = false, that) => {
    const poster = Poster({}, that);
    if (!poster) {
        console.error('请设置组件的id="poster"!!!');
    } else {
        return Poster({}, that).onCreate(reset);
    }
};
export default Poster;
